package tiruvury.InterviewPrep.DataStructureTests;

import java.util.Comparator;
import java.util.PriorityQueue;

import tiruvury.InterviewPrep.DataStructures.MyHeap;
import tiruvury.InterviewPrep.HelperClasses.MaxHeapComparator;

public class MyHeapTests
{
	public static void main(String[] args)
	{
		// Find the median in a set of numbers
		int[] arr = new int[]
		{ 1, 6, 3, 5, 2, 9, -1, 3, 9, 5, 2, 7, 4, 0, 8, 0, 2, 4, 7, 9, 1, 4, 3, 7, 5, 9, 7, 4, 3, 2, 5, 7, 9, 1 };
		Comparator<Integer> maxHeapComparator = new MaxHeapComparator();
		PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>(10, maxHeapComparator);
		PriorityQueue<Integer> minHeap = new PriorityQueue<Integer>(10);
		for (int i = 0; i < arr.length; i++)
		{
			int median = MyHeap.FindMedian(arr[i], maxHeap, minHeap);
			System.out.println("Median so far: " + median);
		}
		System.out.println();
	}

}
